const fs = require("fs");
function myPromisify(fn) {
  return (...rest) => {
    return new Promise((resolve, reject) => {
      fn(...rest, (err, result) => {
        if (err) {
          reject(err);
          return;
        }
        resolve(result);
      });
    });
  };
}

myPromisify(fs.readFile)("./a.txt")
  .then((data) => {
    let resdata = data.toString() + "修改了";
    return myPromisify(fs.writeFile)("./b.txt", resdata);
  })
  .then(() => {
    console.log("写入成功了");
  });
